package org.ykhl.zheer.adaptors;


import org.slf4j.LoggerFactory;
import org.tempuri2.HisService;
import org.tempuri2.HisServiceDelegate;
import org.ykhl.interfaces.commons.AdapterInterface;
import org.ykhl.model.RetInfo;
import org.ykhl.service.ConvertService;

import java.util.Map;

/**
 * Created by wcd on 2017/2/6.
 */
public class Hishospital2 implements AdapterInterface{
    private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(Hishospital2.class);
    private RetInfo retInfo = new RetInfo();
    private HisService hisService=null;

    @Override
    public String getHosMessage(Map<String, Object> params) throws Exception {
        //调用HIS院内系统
        String tradeType = params.get("tradeType").toString();
        String tradeMsg =params.get("requestParam").toString();
        hisService = (HisService) params.get("hisService");
        HisServiceDelegate hd = hisService.getHisService();
        String resp = (String) hd.invoke("adapter.hisService",tradeType,tradeMsg);

        LOG.debug(" Receiver form His webservice  - tradeType: " + tradeType );
        LOG.debug(" Receiver form His webservice  -response Message size:" + resp.length());
        return resp;
    }

    @Override
    public RetInfo trans(Map<String, Object> params) throws Exception {
        Object ob =   params.get("convertService");
        retInfo = ((ConvertService)ob).defaultConversion(params.get("oriMsgBody").toString(),params.get("xslContent").toString(),params.get("key").toString());
        LOG.debug("hospital retInfo  Content:" + retInfo.getContent().length()+", RetCode :" + retInfo.getRetCode());

        return retInfo;
    }
}
